<?php

namespace Apps\AppApi\Method\Note;

use Apps\AppApi\Method\BaseMethod;
use PhalconPlus\Api\Common\ResultStatus;
use Apps\Common\Models\Inorout;
use Phalcon\Mvc\Model;


/**
 * 收支分类二级分类列表
 * @author      545
 * @date        2016年3月4日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class InoroutSecList extends BaseMethod
{
    
    private $success = 0;
    private $id = 0;

    public function run()
    {
        //验证是否登录
        if(false == $this->verifyUserAuth()){
            return false;
        }
        
        $userid = $this->getUserAuth()->userId;
        
        $type = $this->getDataItem('type',1);
        $id = $this->getDataItem('id',0);
        if($id==0){
            return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR,'id不能为空');
        }
        
    	
    	$data = Inorout::query()
        ->columns(['inorout_id', 'inorout_title'])
        ->where('state = 1 AND parent_id = :pid: AND user_id = :uid: AND type = :type:')
        ->bind(['uid'=>$userid,'type'=>$type,'pid'=>$id])
        ->orderBy('inorout_id DESC')
        ->execute()
        ->toArray();
        
        $this->setResult($data);
        
    }

}